package com.ttt.adbgui.function;

import com.ttt.adbgui.jcomp.JFrameComponent;
import com.ttt.adbgui.utils.JavaCMD;
import com.ttt.adbgui.utils.RunCMD;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.swing.*;
import java.util.ArrayList;

/*
* 通过执行adb命令，获取已连接的adb设备
* */

@Component
@Slf4j
public class SelectDevices {
    @Autowired
    private JFrameComponent jFrameComponent;
    @Autowired
    private JavaCMD javaCMD;
    @Autowired
    private RunCMD runCMD;

    public void getDevices(){

        JTable table = jFrameComponent.getTable();
        int selectedColumn = table.getSelectedColumn();
        int selectedRow = table.getSelectedRow();
        String cellValue = String.valueOf(table.getValueAt(selectedRow, selectedColumn));
        log.info("cellValue：{}",cellValue);

        // 更新运行日志
        JTextPane textPane = jFrameComponent.getTextPane();
        // javaCMD.exec(cellValue,textPane);
        runCMD.run(cellValue,textPane);
    }
}
